home *** CD-ROM | disk | FTP | other *** search
/ CD Classic 39 / CD CLASSIC #39 (1998).iso / EMPRESA / visio / Vistdstd / Install / Data.Z / Fields.FRM (.txt) < prev    next >
Visual Basic Form  |  1996-09-04  |  13KB  |  332 lines

  1. VERSION 4.00
  2. Begin VB.Form frmChooseFields 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    Caption         =   "Choose Inventory Fields"
  7.    ClientHeight    =   2295
  8.    ClientLeft      =   165
  9.    ClientTop       =   1605
  10.    ClientWidth     =   6195
  11.    BeginProperty Font 
  12.       name            =   "MS Sans Serif"
  13.       charset         =   0
  14.       weight          =   700
  15.       size            =   8.25
  16.       underline       =   0   'False
  17.       italic          =   0   'False
  18.       strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    Height          =   2700
  22.    Left            =   105
  23.    LinkTopic       =   "Form1"
  24.    MaxButton       =   0   'False
  25.    MinButton       =   0   'False
  26.    ScaleHeight     =   2295
  27.    ScaleWidth      =   6195
  28.    Top             =   1260
  29.    Width           =   6315
  30.    Begin VB.CommandButton btnCancel 
  31.       Appearance      =   0  'Flat
  32.       BackColor       =   &H80000005&
  33.       Caption         =   "&Cancel"
  34.       Height          =   375
  35.       Left            =   5100
  36.       TabIndex        =   9
  37.       Top             =   480
  38.       Width           =   1035
  39.    End
  40.    Begin VB.CommandButton btnOK 
  41.       Appearance      =   0  'Flat
  42.       BackColor       =   &H80000005&
  43.       Caption         =   "&Ok"
  44.       Height          =   375
  45.       Left            =   5100
  46.       TabIndex        =   8
  47.       Top             =   60
  48.       Width           =   1035
  49.    End
  50.    Begin VB.ListBox ctlUsedList 
  51.       Appearance      =   0  'Flat
  52.       Height          =   2175
  53.       Left            =   3120
  54.       TabIndex        =   1
  55.       Top             =   60
  56.       Width           =   1935
  57.    End
  58.    Begin VB.ListBox ctlUnusedList 
  59.       Appearance      =   0  'Flat
  60.       Height          =   2175
  61.       Left            =   60
  62.       TabIndex        =   0
  63.       Top             =   60
  64.       Width           =   1935
  65.    End
  66.    Begin Threed.SSCommand btnMoveDown 
  67.       Height          =   375
  68.       Left            =   5100
  69.       TabIndex        =   7
  70.       Top             =   1860
  71.       Width           =   1035
  72.       _Version        =   65536
  73.       _ExtentX        =   1826
  74.       _ExtentY        =   661
  75.       _StockProps     =   78
  76.       Picture         =   "FIELDS.frx":0000
  77.    End
  78.    Begin Threed.SSCommand btnMoveUp 
  79.       Height          =   360
  80.       Left            =   5100
  81.       TabIndex        =   6
  82.       Top             =   1440
  83.       Width           =   1020
  84.       _Version        =   65536
  85.       _ExtentX        =   1799
  86.       _ExtentY        =   635
  87.       _StockProps     =   78
  88.       Picture         =   "FIELDS.frx":0112
  89.    End
  90.    Begin Threed.SSCommand btnDeleteAll 
  91.       Height          =   375
  92.       Left            =   2040
  93.       TabIndex        =   5
  94.       Top             =   1860
  95.       Width           =   1035
  96.       _Version        =   65536
  97.       _ExtentX        =   1826
  98.       _ExtentY        =   661
  99.       _StockProps     =   78
  100.       Picture         =   "FIELDS.frx":0224
  101.    End
  102.    Begin Threed.SSCommand btnDelete 
  103.       Height          =   375
  104.       Left            =   2040
  105.       TabIndex        =   4
  106.       Top             =   1260
  107.       Width           =   1035
  108.       _Version        =   65536
  109.       _ExtentX        =   1826
  110.       _ExtentY        =   661
  111.       _StockProps     =   78
  112.       Picture         =   "FIELDS.frx":03B6
  113.    End
  114.    Begin Threed.SSCommand btnAdd 
  115.       Height          =   375
  116.       Left            =   2040
  117.       TabIndex        =   3
  118.       Top             =   660
  119.       Width           =   1035
  120.       _Version        =   65536
  121.       _ExtentX        =   1826
  122.       _ExtentY        =   661
  123.       _StockProps     =   78
  124.       Picture         =   "FIELDS.frx":04C8
  125.    End
  126.    Begin Threed.SSCommand btnAddAll 
  127.       Height          =   375
  128.       Left            =   2040
  129.       TabIndex        =   2
  130.       Top             =   60
  131.       Width           =   1035
  132.       _Version        =   65536
  133.       _ExtentX        =   1826
  134.       _ExtentY        =   661
  135.       _StockProps     =   78
  136.       Picture         =   "FIELDS.frx":05DA
  137.    End
  138. Attribute VB_Name = "frmChooseFields"
  139. Attribute VB_Creatable = False
  140. Attribute VB_Exposed = False
  141. ' -----------------------------------------------------------------------------
  142. ' Copyright (C) 1993-1996 Visio Corporation. All rights reserved.
  143. ' You have a royalty-free right to use, modify, reproduce and distribute
  144. ' the Sample Application Files (and/or any modified version) in any way
  145. ' you find useful, provided that you agree that Visio has no warranty,
  146. ' obligations or liability for any Sample Application Files.
  147. ' -----------------------------------------------------------------------------
  148. Option Explicit
  149. Option Base 1
  150. '-- Specifies if OK was pressed before unloading.
  151. Dim m_iOkPushed As Integer
  152. '-- List Declarations : We keep three globals to maintain the used and unused
  153. '--                     list boxes.  m_iUnusedCount maintains the number of
  154. '--                     unused fields.  The two global lists are self explani-
  155. '--                     tory.  Note that they are always dimension to be as
  156. '--                     large as FieldCount since either may grow that large.
  157. '--                     This offers a pretty easy way to manipulate the order
  158. '--                     as well as who is used or not and isn't too tricky.
  159. Dim m_iUnusedCount As Integer
  160. Dim m_UnusedList() As Integer
  161. Dim m_UsedList() As Integer
  162. Private Sub btnAdd_Click()
  163. '------------------------------------
  164. '--- btnAdd_Click -------------------
  165. '--   When the add button is pressed we move the field index from the unused
  166. '-- list box to the end of the Used list.  We must then slide all indexes past
  167. '-- it down one in the array.
  168.     Dim I As Integer, iPos As Integer
  169.     If ctlUnusedList.ListIndex = -1 Or ctlUnusedList.ListCount < 1 Then Exit Sub
  170.     iPos = ctlUnusedList.ListIndex + 1
  171.     m_iUnusedCount = m_iUnusedCount - 1
  172.     m_UsedList(FieldCount() - m_iUnusedCount) = m_UnusedList(iPos)
  173.     If iPos < ctlUnusedList.ListCount Then
  174.         For I = iPos To m_iUnusedCount
  175.             m_UnusedList(I) = m_UnusedList(I + 1)
  176.         Next I
  177.     End If
  178.     UpdateListBoxes -1, -1
  179. End Sub
  180. Private Sub btnAddAll_Click()
  181. '------------------------------------
  182. '--- btnAddAll_Click ----------------
  183. '--   Adds all unused fields to the end of the used array
  184.     Dim I As Integer
  185.     For I = 1 To FieldCount()
  186.         m_UsedList(I) = I - 1
  187.     Next I
  188.     m_iUnusedCount = 0
  189.     UpdateListBoxes -1, -1
  190. End Sub
  191. Private Sub btnCancel_Click()
  192.     m_iOkPushed = False
  193.     Unload frmChooseFields
  194. End Sub
  195. Private Sub btnDelete_Click()
  196. '------------------------------------
  197. '--- btnDelete_Click ----------------
  198. '--   When the delete button is pressed we move the field index from the used
  199. '-- list to the unused one.  It is appended to the end of it.  We must then
  200. '-- slide all the indexes above it down in the array by one.
  201.     Dim I As Integer, iPos As Integer
  202.     If ctlUsedList.ListIndex = -1 Or ctlUsedList.ListCount < 2 Then Exit Sub
  203.     iPos = ctlUsedList.ListIndex + 1
  204.     m_iUnusedCount = m_iUnusedCount + 1
  205.     m_UnusedList(m_iUnusedCount) = m_UsedList(iPos)
  206.     If iPos < ctlUsedList.ListCount Then
  207.         For I = iPos To FieldCount() - m_iUnusedCount
  208.             m_UsedList(I) = m_UsedList(I + 1)
  209.         Next I
  210.     End If
  211.     UpdateListBoxes -1, -1
  212. End Sub
  213. Private Sub btnDeleteAll_Click()
  214. '------------------------------------
  215. '--- btnDeleteAll_Click -------------
  216. '--   Moves every field to the unused list except the first field in the
  217. '-- used list.  This is because there must be at least one field included.
  218.     Dim I As Integer, iPos As Integer
  219.     iPos = 0
  220.     For I = 1 To FieldCount()                       '-- For Each Field...
  221.         If m_UsedList(1) <> I - 1 Then              '--   If Not First Used...
  222.             iPos = iPos + 1                         '--
  223.             m_UnusedList(iPos) = I - 1                 '--     Copy It!
  224.         End If
  225.     Next I
  226.     m_iUnusedCount = FieldCount() - 1               '-- Set Unused Count
  227.     UpdateListBoxes -1, -1                          '-- Update Lists
  228. End Sub
  229. Private Sub btnMoveDown_Click()
  230. '------------------------------------
  231. '--- btnMoveDown_Click --------------
  232. '--   When the down arrow button is pushed we move the selected used list field
  233. '-- down one in the list unless it's already at the bottom.
  234.     Dim iTemp As Integer, iPos As Integer
  235.     If ctlUsedList.ListIndex = -1 Or ctlUsedList.ListCount < 1 Then Exit Sub
  236.     If Not (ctlUsedList.ListIndex + 1 < ctlUsedList.ListCount) Then Exit Sub
  237.         
  238.     iPos = ctlUsedList.ListIndex + 1
  239.     iTemp = m_UsedList(iPos)
  240.     m_UsedList(iPos) = m_UsedList(iPos + 1)
  241.     m_UsedList(iPos + 1) = iTemp
  242.     UpdateListBoxes (ctlUnusedList.ListIndex), iPos
  243. End Sub
  244. Private Sub btnMoveUp_Click()
  245. '------------------------------------
  246. '--- btnMoveUp_Click ----------------
  247. '--   When the user clicks the up arrow button we move one of the fields in
  248. '-- the used list up a notch if and only if it's not at the top of the list.
  249.     Dim iTemp As Integer, iPos As Integer
  250.     If ctlUsedList.ListIndex = -1 Or ctlUsedList.ListIndex < 1 Then Exit Sub
  251.     If ctlUsedList.ListCount < 1 Then Exit Sub
  252.         
  253.     iPos = ctlUsedList.ListIndex + 1
  254.     iTemp = m_UsedList(iPos)
  255.     m_UsedList(iPos) = m_UsedList(iPos - 1)
  256.     m_UsedList(iPos - 1) = iTemp
  257.     UpdateListBoxes (ctlUnusedList.ListIndex), iPos - 2
  258. End Sub
  259. Private Sub btnOK_Click()
  260. '------------------------------------
  261. '--- btnOK_Click --------------------
  262. '--   When OK is clicked we loop through the used and unused list and set their
  263. '-- include flags in the main fields list.  After that we simply unload the form.
  264.     Dim I As Integer, iTemp As Integer
  265.     iTemp = SetIncludeFlag(m_UsedList(1), True)
  266.     For I = 0 To FieldCount() - 1
  267.         If I <> m_UsedList(1) Then
  268.             If Not SetIncludeFlag(I, False) Then
  269.                 MsgBox "Error Setting Include Flag (Reset)"
  270.             End If
  271.         End If
  272.     Next I
  273.     For I = 1 To FieldCount() - m_iUnusedCount
  274.         If Not SetIncludeFlag(m_UsedList(I), True) Then
  275.             MsgBox "Error Setting Include Flag (Used)"
  276.         End If
  277.     Next I
  278.     m_iOkPushed = True
  279.     Unload frmChooseFields
  280. End Sub
  281. Private Sub ctlUnusedList_DblClick()
  282.     btnAdd_Click
  283. End Sub
  284. Private Sub ctlUsedList_DblClick()
  285.     btnDelete_Click
  286. End Sub
  287. Private Function DoModal() As Integer
  288.     frmChooseFields.Show 1
  289.     DoModal = m_iOkPushed
  290. End Function
  291. Private Sub Form_Load()
  292. '------------------------------------
  293. '--- Form_Load ----------------------
  294. '--   Upon loading we initialize the used and unused lists.  Then we update
  295. '-- their list boxes.
  296.     Dim I As Integer, iUnused As Integer, iTemp As Integer
  297.     m_iUnusedCount = FieldCount() - IncludeCount()
  298.     If FieldCount() = 0 Then Unload frmChooseFields
  299.     ReDim m_UsedList(FieldCount())
  300.     ReDim m_UnusedList(FieldCount())
  301.     For I = 0 To FieldCount() - 1
  302.         iTemp = IncludeIndex(I)
  303.         If iTemp <> -1 Then
  304.             m_UsedList(iTemp + 1) = I
  305.         Else
  306.             iUnused = iUnused + 1
  307.             m_UnusedList(iUnused) = I
  308.         End If
  309.     Next I
  310.     UpdateListBoxes -1, -1
  311. End Sub
  312. Private Sub UpdateListBoxes(iUnUsedIndex As Integer, iUsedIndex As Integer)
  313. '------------------------------------
  314. '--- UpdateListBoxes ----------------
  315. '--   Updates the used and unused list boxes to reflect their respective fields.
  316.     Dim I As Integer
  317.     ctlUsedList.Clear                           '-- Clear List Boxes
  318.     ctlUnusedList.Clear
  319.     If FieldCount() - m_iUnusedCount > 0 Then
  320.         For I = 1 To FieldCount() - m_iUnusedCount
  321.             ctlUsedList.AddItem FieldNames(m_UsedList(I))
  322.         Next I
  323.         If iUsedIndex <> -1 Then ctlUsedList.ListIndex = iUsedIndex
  324.     End If
  325.     If m_iUnusedCount > 0 Then
  326.         For I = 1 To m_iUnusedCount
  327.             ctlUnusedList.AddItem FieldNames(m_UnusedList(I))
  328.         Next I
  329.         If iUnUsedIndex <> -1 Then ctlUnusedList.ListIndex = iUnUsedIndex
  330.     End If
  331. End Sub
  332.